<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="WHIT">
<span class='line'>  2</span> </span><span class="COMM">/**
<span class='line'>  3</span>  * @fileoverview Implementation of HTML5 input type="date" control.
<span class='line'>  4</span>  * @link http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml
<span class='line'>  5</span>  * @link https://developers.google.com/closure/compiler/docs/js-for-compiler
<span class='line'>  6</span>  */</span><span class="WHIT">
<span class='line'>  7</span> 
<span class='line'>  8</span> 
<span class='line'>  9</span> 
<span class='line'> 10</span> </span><span class="COMM">/**
<span class='line'> 11</span>  * Constructor of InputDate.&lt;br>
<span class='line'> 12</span>  * The following 8 pseudo-elements are made available by WebKit for customizing
<span class='line'> 13</span>  * a date input’s textbox:&lt;code>&lt;pre>
<span class='line'> 14</span>  *   ::-webkit-datetime-edit { padding: 1em; }
<span class='line'> 15</span>  *   ::-webkit-datetime-edit-fields-wrapper { background: silver; }
<span class='line'> 16</span>  *   ::-webkit-datetime-edit-text { color: red; padding: 0 0.3em; }
<span class='line'> 17</span>  *   ::-webkit-datetime-edit-month-field { color: blue; }
<span class='line'> 18</span>  *   ::-webkit-datetime-edit-day-field { color: green; }
<span class='line'> 19</span>  *   ::-webkit-datetime-edit-year-field { color: purple; }
<span class='line'> 20</span>  *   ::-webkit-inner-spin-button { display: none; }
<span class='line'> 21</span>  *   ::-webkit-calendar-picker-indicator { background: orange; }
<span class='line'> 22</span>  * &lt;/pre>&lt;/code>
<span class='line'> 23</span>  * @param {string|Element} input The input element or its ID attribute.
<span class='line'> 24</span>  * @constructor
<span class='line'> 25</span>  * @requires controls.DatePicker
<span class='line'> 26</span>  * @requires formatters.DateFormatter
<span class='line'> 27</span>  * @link http://www.w3.org/TR/html-markup/input.date.html
<span class='line'> 28</span>  */</span><span class="WHIT">
<span class='line'> 29</span> </span><span class="NAME">controls.html5.InputDate</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">input</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 30</span> </span><span class="WHIT">  </span><span class="COMM">// http://trac.webkit.org/wiki/Styling%20Form%20Controls</span><span class="WHIT">
<span class='line'> 31</span> </span><span class="WHIT">  </span><span class="COMM">// There are no ways to specify the date format in the text box. It always</span><span class="WHIT">
<span class='line'> 32</span> </span><span class="WHIT">  </span><span class="COMM">// reflects OS setting. Also, there are no ways to styling the native</span><span class="WHIT">
<span class='line'> 33</span> </span><span class="WHIT">  </span><span class="COMM">// calendar picker.</span><span class="WHIT">
<span class='line'> 34</span> 
<span class='line'> 35</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'> 36</span>    * @private
<span class='line'> 37</span>    */</span><span class="WHIT">
<span class='line'> 38</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">init_</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 39</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">'date'</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">input_.type</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 40</span> </span><span class="WHIT">      </span><span class="NAME">picker_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">controls.DatePicker</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 41</span> </span><span class="WHIT">      </span><span class="NAME">dom.events.addEventListener</span><span class="PUNC">(</span><span class="NAME">input_</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">dom.events.TYPE.CLICK</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">mousedown_</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 42</span> </span><span class="WHIT">      </span><span class="NAME">dom.events.addEventListener</span><span class="PUNC">(</span><span class="NAME">input_</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">dom.events.TYPE.CHANGE</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">change_</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 43</span> </span><span class="WHIT">      </span><span class="NAME">input_.readOnly</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 44</span> 
<span class='line'> 45</span> </span><span class="WHIT">      </span><span class="COMM">// -moz-appearance: menulist;</span><span class="WHIT">
<span class='line'> 46</span> </span><span class="WHIT">      </span><span class="COMM">// -webkit-appearance: menulist;</span><span class="WHIT">
<span class='line'> 47</span> 
<span class='line'> 48</span> </span><span class="WHIT">      </span><span class="COMM">//input_.style.backgroundImage = 'url(data:image/png;base64,' +  + ')';</span><span class="WHIT">
<span class='line'> 49</span> </span><span class="WHIT">      </span><span class="COMM">//input_.style.backgroundPosition = 'right center';</span><span class="WHIT">
<span class='line'> 50</span> </span><span class="WHIT">      </span><span class="COMM">//input_.style.backgroundRepeat = 'no-repeat';</span><span class="WHIT">
<span class='line'> 51</span> </span><span class="WHIT">      </span><span class="COMM">//input_.style.paddingRight = PADDING + 'px';</span><span class="WHIT">
<span class='line'> 52</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 53</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 54</span> 
<span class='line'> 55</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'> 56</span>    * @param {Event} e The mousedown event.
<span class='line'> 57</span>    * @private
<span class='line'> 58</span>    */</span><span class="WHIT">
<span class='line'> 59</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">mousedown_</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 60</span> </span><span class="WHIT">    </span><span class="NAME">picker_.show</span><span class="PUNC">(</span><span class="NAME">input_</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 61</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 62</span> 
<span class='line'> 63</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'> 64</span>    * @param {Event} e The onchange event.
<span class='line'> 65</span>    * @private
<span class='line'> 66</span>    */</span><span class="WHIT">
<span class='line'> 67</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">change_</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 68</span> </span><span class="WHIT">    </span><span class="COMM">/** @type {string} */</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">format</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">picker_.getFormat</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 69</span> </span><span class="WHIT">    </span><span class="COMM">/** @type {Date} */</span><span class="WHIT">
<span class='line'> 70</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">formatters.DateFormatter.parse</span><span class="PUNC">(</span><span class="NAME">input_.value</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 71</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 72</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">max_</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 73</span> </span><span class="WHIT">        </span><span class="COMM">/** @type {Date} */</span><span class="WHIT">
<span class='line'> 74</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">max</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">formatters.DateFormatter.parse</span><span class="PUNC">(</span><span class="NAME">max_</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 75</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NAME">max</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 76</span> </span><span class="WHIT">          </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">max</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 77</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 78</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 79</span> 
<span class='line'> 80</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">min_</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 81</span> </span><span class="WHIT">        </span><span class="COMM">/** @type {Date} */</span><span class="WHIT">
<span class='line'> 82</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">min</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">formatters.DateFormatter.parse</span><span class="PUNC">(</span><span class="NAME">min_</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 83</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">min</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 84</span> </span><span class="WHIT">          </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">min</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 85</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 86</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 87</span> 
<span class='line'> 88</span> </span><span class="WHIT">      </span><span class="NAME">input_.value</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">formatters.DateFormatter.format</span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 89</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 90</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 91</span> 
<span class='line'> 92</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'> 93</span>    * @type {controls.DatePicker}
<span class='line'> 94</span>    * @private
<span class='line'> 95</span>    */</span><span class="WHIT">
<span class='line'> 96</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">picker_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 97</span> 
<span class='line'> 98</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'> 99</span>    * The reference to input element.
<span class='line'>100</span>    * @type {Element}
<span class='line'>101</span>    * @private
<span class='line'>102</span>    */</span><span class="WHIT">
<span class='line'>103</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">input_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">input</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">dom.getElementById</span><span class="PUNC">(</span><span class="NAME">input</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">input</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>104</span> 
<span class='line'>105</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>106</span>    * The expected lower bound for the input value.
<span class='line'>107</span>    * A valid full-date as defined in [RFC 3339].
<span class='line'>108</span>    * @link http://tools.ietf.org/html/rfc3339
<span class='line'>109</span>    * @type {string}
<span class='line'>110</span>    * @private
<span class='line'>111</span>    */</span><span class="WHIT">
<span class='line'>112</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">min_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">input_.getAttribute</span><span class="PUNC">(</span><span class="STRN">'min'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>113</span> 
<span class='line'>114</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>115</span>    * The expected upper bound for the input value.
<span class='line'>116</span>    * A valid full-date as defined in [RFC 3339].
<span class='line'>117</span>    * @link http://tools.ietf.org/html/rfc3339
<span class='line'>118</span>    * @type {string}
<span class='line'>119</span>    * @private
<span class='line'>120</span>    */</span><span class="WHIT">
<span class='line'>121</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">max_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">input_.getAttribute</span><span class="PUNC">(</span><span class="STRN">'max'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>122</span> 
<span class='line'>123</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>124</span>    * Specifies the value granularity of the input value.
<span class='line'>125</span>    * Currently not used.
<span class='line'>126</span>    * @type {number}
<span class='line'>127</span>    * @private
<span class='line'>128</span>    */</span><span class="WHIT">
<span class='line'>129</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">step_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">(</span><span class="NAME">input_.getAttribute</span><span class="PUNC">(</span><span class="STRN">'step'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>130</span> 
<span class='line'>131</span> </span><span class="WHIT">  </span><span class="NAME">init_</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>132</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>133</span> </span></pre></body></html>